package com.kefu.chat.vo;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.kefu.chat.model.ChatConversationMsg;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author CodeGenerator
 * @date 2022/08/15
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "内部会话消息")
public class ChatConversationMsgSendVo extends AbstractInsertVo<ChatConversationMsg> {

    @ApiModelProperty(value = "内部会话id")
    private String conversationId;
    @ApiModelProperty(value = "消息类型：1.文字，2图片，3富文本，4文件，5音频，6视频")
    private Integer msgType;
    @ApiModelProperty(value = "文件名字")
    private String fileName;
    @ApiModelProperty(value = "音频时长，秒")
    private Integer audioDuration;
    @ApiModelProperty(value = "消息内容")
    private String msgContent;

    @Override
    public ChatConversationMsg convert() {
        ChatConversationMsg info = new ChatConversationMsg();
	    info.setConversationId(conversationId);
	    info.setMsgType(msgType);
	    info.setFileName(fileName);
	    info.setAudioDuration(audioDuration);
	    info.setMsgContent(msgContent);
        KefuContext context = KefuContext.getKefuContext();
	    info.setTenantId(context.getTenantId());
        info.setMsgTime(context.getNow());
        info.setSender(context.getUserId());
        info.setSenderName(context.getUserName());
        info.setMsgId(IdWorker.getIdStr());
        return info;
	}
}